﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GraphGeneric;
using System.Windows.Media.Animation;

namespace GraphGenericTestApp
{
	/// <summary>
	/// Interaction logic for Window1.xaml
	/// </summary>
	public partial class Window1 : Window
	{
		public Window1()
		{
			InitializeComponent();
		}

        protected override void OnInitialized(EventArgs e)
        {
            m_graphViewer.Loaded += new RoutedEventHandler(m_graphViewer_Loaded);
            NamesListBox.SelectionChanged += new SelectionChangedEventHandler(NamesListBox_SelectionChanged);
            base.OnInitialized(e);
        }

        void NamesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            m_graphViewer.ChangeRootNode(e.AddedItems[0] as string);   
        }

        void m_graphViewer_Loaded(object sender, RoutedEventArgs e)
        {
            NamesListBox.ItemsSource = m_graphViewer.CurrentNames;
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            m_graphViewerOld.RepositionNodes();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            m_graphViewerOld.Zoom *= 1.5;
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            m_graphViewerOld.Zoom *= .5;
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            m_graphViewerOld.DrawEdges();
        }

        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            if (borderNew.IsVisible)
            {
                borderNew.Visibility = Visibility.Collapsed;
                borderold.Visibility = Visibility.Visible;
            }
            else
            {
                borderNew.Visibility = Visibility.Visible;
                borderold.Visibility = Visibility.Collapsed;
            }
        }
	}
}
